﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：马毅
    //
    // 文件名：OrderTimeOut.cs
    // 文件功能描述：过期订单的查询
    // 创建标识：马毅 2009-05-13
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;
namespace HZ.DrugTrade.Web.Enterprise.OrderManage
{
    public partial class OrderTimeOut : BasePage
    {
        IBLL_Purchase iPurchase = Factory.BLL_Purchase();
        IBLL_ProcurementBasic ipb = Factory.BLL_ProcurementBasic();

        public OrderTimeOut()
        {
            this.ModuleNo = Module.订单管理.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setBind();
            }
        } 
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            setBind();
        }

        protected void lbnSwitch_Click(object sender, EventArgs e)
        {
            if (lbnSwitch.CommandArgument == "simple")
            {
                ltlAdvance.Text = "";
                lbnSwitch.CommandArgument = "advance";
                lbnSwitch.Text = "简单查询";
            }
            else
            {
                ltlAdvance.Text = "<tbody id='advance' style='display:none'>";
                lbnSwitch.CommandArgument = "simple";
                lbnSwitch.Text = "高级查询";

                //清空数据 
      
                txtGoodsName.Text = "";
                txtOutLookc.Text = "";
                txtPurchaseTimeBegin.Text = "";
                txtPurchaseTimeEnd.Text = "";
                txtHospitalName.Text = "";
                txtDetailOrderName.Text = "";
                txtPinyinCode.Text = "";
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            setBind();
        }

        private void setBind()
        {
            //获取查询条件
            Model.Query.Distribution qryCondition = new HZ.DrugTrade.Model.Query.Distribution();
            qryCondition.CompanyID_PS = CurrentAccount.GetUser().Org.OrgID;

            qryCondition.PinyinCode = this.txtPinyinCode.Text.Trim().ToUpper();
            qryCondition.GoodsName = this.txtGoodsName.Text.Trim();
            qryCondition.OrderName = this.txtDetailOrderName.Text.Trim();//strOrderName;
            qryCondition.HospitalName = this.txtHospitalName.Text.Trim(); //strHospitalName;
            qryCondition.StartTimeFrom = new HZ.Common.ConvertHelper(this.txtPurchaseTimeBegin.Text.Trim()).ToDateTime;  
            qryCondition.StartTimeTo = new HZ.Common.ConvertHelper(this.txtPurchaseTimeEnd.Text.Trim()).ToDateTime;  
            qryCondition.Outlookc = this.txtOutLookc.Text.Trim(); //strOutlookc;
            qryCondition.Material = this.txtMaterial.Text.Trim(); //材质
           
            qryCondition.SortFields = " StartTime desc "; 

            //调用方法，执行查询，分页显示产品信息
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalRecord =0;
            try
            {
                IList<Model.View.Distribution> VDistribution = new List<Model.View.Distribution>();
                VDistribution = iPurchase.GetPurchaseOrderDetail_OverdueByWhere(qryCondition, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRecord);
                IList<HZ.DrugTrade.Model.View.Distribution> PurchaseOrderOverdueList = VDistribution;
                AspNetPager1.RecordCount = totalRecord;
                gvwProduceCatalog.DataSource = PurchaseOrderOverdueList;
                gvwProduceCatalog.DataBind();
            }
            catch (Exception ex)
            { 
                PageError(ex.Message, "");
            }
        }

        /// <summary>
        /// 已不使用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwProduceCatalog_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //0未提交;1已提交;2已确认;3拒绝确认
                //Literal ltr = e.Row.FindControl("OrderDetailState") as Literal;
              
               
                //if (e.Row.Cells[22].Text == "1")
                //{
                //    e.Row.Cells[22].Text = "已提交";
                //}
                //    else if (e.Row.Cells[22].Text == "2")
                //{
                //    e.Row.Cells[22].Text = "已确认";

                //}
                //    else if (e.Row.Cells[22].Text == "3")
                //{
                //    e.Row.Cells[22].Text = "拒绝配送";

                //}
            }
        }
    }  
}
